home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Commodities / ToBack&Front / myparseix.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  3KB  |  106 lines

  1. /*
  2.  *  myparseix.c - frontend to ParseIX() to allow trapping of mousebutton codes
  3.  *
  4.  *  Author: Stefan Sticht
  5.  *
  6.  *  Version history:
  7.  *
  8.  *  V1.00   initial hack
  9.  */
  10.  
  11. /********************************************************************
  12.  *                             interfacing                          *
  13.  ********************************************************************/
  14.  
  15. /*
  16.  *  include files
  17.  */
  18. #include <string.h>
  19. #include <devices/inputevent.h>
  20. #include <libraries/commodities.h>
  21. #include <clib/commodities_protos.h>
  22. #include <pragmas/commodities_pragmas.h>
  23.  
  24. #ifdef DEBUG
  25. #define printf KPrintF
  26. #include <clib/dlib_protos.h>
  27. #endif
  28.  
  29. extern struct Library *CxBase;
  30.  
  31. /********************************************************************
  32.  *                             functions                            *
  33.  ********************************************************************/
  34.  
  35. long myparseix(char *description, IX *ix)
  36. {
  37.     char blanks[] = "           ";
  38.     char *pos;
  39.     long failurecode = 0l;
  40.     UWORD code = 0;
  41.  
  42.     #ifdef DEBUG
  43.     printf("myparseix(): description is %s\n", description);
  44.     #endif
  45.  
  46.     /*
  47.      *  parse and remove our special keywords
  48.      *
  49.      */
  50.     if (pos = strstr(description, "lbuttoncode")) {
  51.         code |= IECODE_LBUTTON;
  52.         strncpy(pos, blanks, 11l);
  53.         }
  54.     else if (pos = strstr(description, "rbuttoncode")) {
  55.         code |= IECODE_RBUTTON;
  56.         strncpy(pos, blanks, 11l);
  57.         }
  58.     else if (pos = strstr(description, "mbuttoncode")) {
  59.         code |= IECODE_MBUTTON;
  60.         strncpy(pos, blanks, 11l);
  61.         }
  62.  
  63.     while (*description && (*description == ' ')) description++;
  64.  
  65.     #ifdef DEBUG
  66.     printf("myparseix(): description changed to %s\n", description);
  67.     #endif
  68.  
  69.     if (*description) failurecode = ParseIX((UBYTE *)description, ix);
  70.  
  71.     /*
  72.      *  now change ix for our new keywords
  73.      *
  74.      */
  75.     if (code) {
  76.         ix->ix_Code |= code;
  77.         /*
  78.          *  change also QualMask for mouse buttons
  79.          *
  80.          */
  81.         ix->ix_QualMask |= IEQUALIFIER_MIDBUTTON | IEQUALIFIER_RBUTTON | IEQUALIFIER_LEFTBUTTON;
  82.  
  83.         /*
  84.          *  parse for qualifiers the use wants to be considered irrelevant
  85.          *
  86.          */
  87.         if (strstr(description, "-leftbutton")) ix->ix_QualMask &= ~IEQUALIFIER_LEFTBUTTON;
  88.         if (strstr(description, "-midbutton")) ix->ix_QualMask &= ~IEQUALIFIER_MIDBUTTON;
  89.         if (strstr(description, "-rbutton")) ix->ix_QualMask &= ~IEQUALIFIER_RBUTTON;
  90.         }
  91.  
  92.     #ifdef DEBUG
  93.     printf("myparseix(): final IX:\n");
  94.     printf("ix_Version      = %ld\n", ix->ix_Version);
  95.     printf("ix_Class        = 0x%lx\n", ix->ix_Class);
  96.     printf("ix_Code         = 0x%lx\n", ix->ix_Code);
  97.     printf("ix_CodeMask     = 0x%lx\n", ix->ix_CodeMask);
  98.     printf("ix_Qualifier    = 0x%lx\n", ix->ix_Qualifier);
  99.     printf("ix_QualMask     = 0x%lx\n", ix->ix_QualMask);
  100.     printf("ix_QualSame     = 0x%lx\n", ix->ix_QualSame);
  101.     if (failurecode) printf("myparseix(): failed!\n");
  102.     #endif
  103.  
  104.     return(failurecode);
  105. }
  106.